function getRandomRobotSpawn()
	local spawns = ents.FindByClass("info_robot_start");
	return table.remove(spawns, math.random(#spawns));
end

function moveContraption(ent, spawnPos)
	if(ValidEntity(ent)) then
		local corePos = ent:GetPos();
		local constraints = constraint.GetAllConstrainedEntities(ent);
		
		for _,Ent in pairs(constraints) do
			local constraintPhys = Ent:GetPhysicsObject();
			if(constraintPhys && constraintPhys:IsValid()) then
				constraintPhys:EnableMotion(true);
				constraintPhys:Wake();
				constraintPhys:ApplyForceCenter(Vector(0, 0, -1));
				
				Ent:SetPos((Ent:GetPos() - corePos + spawnPos));
			end
		end
		ent:SetPos(spawnPos);
		phys = ent:GetPhysicsObject();
		if(phys && phys:IsValid()) then
			phys:EnableMotion(true);
			phys:Wake();
			phys:ApplyForceCenter(Vector(0, 0, -1));
		end
	end
end

function sendMotd()
	local content = "<p>Hello! This is your Message of the Day, otherwise known as the MOTD. You may create a file called motd.txt in your garrysmod/data/garrysbots directory, there you can define your motd message</p>";
	local motdFile = "garrysbots/motd.txt";
	if(file.Exists(motdFile)) then
		content = file.Read(motdFile);
	end
	datastream.StreamToClients(player.GetAll(), "MotdStream", { ["text"] = content });
end

function giveWeapons(ply)
	ply:StripWeapons();
	ply:Give("weapon_physcannon")
	ply:Give("weapon_physgun")
	ply:Give("weapon_pistol")
	ply:Give("weapon_smg")
	ply:Give("gmod_tool")
	ply:Give("gmod_camera")
end

function getRobotCore(ply)
	return ply:GetNetworkedEntity("robot_core");
end